package com.mdhw.utils;

/**
 * @author admin
 * @version 1.0.0
 * @ClassName AesUtil.java
 * @Description
 * @createTime 2022年04月29日 16:00:00
 */
public class AesUtil {
    private String Key;
    private String Iv;
    private static final String CBC_PKCS5_PADDING = "AES/CBC/PKCS5Padding";
    private static final String AES = "AES";
    //构造函数进行初始化key和iv（随机生成）
    public AesUtil(){
        this.Key = getRandom(32);
        this.Iv = getRandom(16);
    }
    public String getKey(){
        return this.Key;
    }
    public String getIv(){
        return this.Iv;
    }
    public static String getRandom(int length){
        char[] arr = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k',
                'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
        String result = String.valueOf(arr[(int)Math.floor(Math.random()*36)]);
        for(int i = 1;i<length;i++){
            result+=arr[(int)Math.floor(Math.random()*36)];
        }
        return result;
    }

}
